package com.zjb.demo.system.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.zjb.demo.common.listener.BaseOnListener;
import com.zjb.demo.common.domain.dto.LogicalDeletionEntity;
import com.zjb.demo.framework.converter.DataScopeConverter;
import org.noear.solon.validation.annotation.Size;

import java.io.Serial;
import java.util.Set;

/**
 * @author 庄佳彬
 * @since 2023/12/28 22:54
 */
@Table(value = "sys_role", onInsert = BaseOnListener.class, onUpdate = BaseOnListener.class)
public class SysRole extends LogicalDeletionEntity {
    @Serial
    private static final long serialVersionUID = 1L;

    public SysRole(Long roleId) {
        this.roleId = roleId;
    }

    public SysRole() {
    }

    /**
     * 角色ID
     */
    @Id(keyType = KeyType.Generator, value = KeyGenerators.flexId)
    @ExcelProperty(value = "角色序号")
    @Column(value = "role_id")
    private Long roleId;

    /**
     * 角色名称
     */
//    @NotBlank(message = "角色名称不能为空")
    @Size(max = 30, message = "角色名称长度不能超过30个字符")
    @ExcelProperty(value = "角色名称")
    @Column(value = "role_name")
    private String roleName;

    /**
     * 角色权限
     */
//    @NotBlank(message = "权限字符不能为空")
    @Size(max = 100, message = "权限字符长度不能超过100个字符")
    @ExcelProperty(value = "角色权限")
    @Column(value = "role_key")
    private String roleKey;

    /**
     * 角色排序
     */
//    @NotNull(message = "显示顺序不能为空")
    @ExcelProperty(value = "角色排序")
    @Column(value = "role_sort")
    private Integer roleSort;

    /**
     * 数据范围（1：所有数据权限；2：自定义数据权限；3：本部门数据权限；4：本部门及以下数据权限；5：仅本人数据权限）
     */
    @ExcelProperty(value = "数据范围", converter = DataScopeConverter.class)
    @Column(value = "data_scope")
    private String dataScope;

    /**
     * 菜单树选择项是否关联显示（ 0：父子不互相关联显示 1：父子互相关联显示）
     */
    @Column(value = "menu_check_strictly")
    private boolean menuCheckStrictly;

    /**
     * 部门树选择项是否关联显示（0：父子不互相关联显示 1：父子互相关联显示 ）
     */
    @Column(value = "dept_check_strictly")
    private boolean deptCheckStrictly;

    /**
     * 角色状态（0正常 1停用）
     */
    @ExcelProperty(value = "角色状态")
    @Column(value = "status")
    private String status;

    /**
     * 用户是否存在此角色标识 默认不存在
     */
    @Column(ignore = true)
    private boolean flag;

    /**
     * 菜单组
     */

    @Column(ignore = true)
    private Long[] menuIds;

    /**
     * 部门组（数据权限）
     */

    @Column(ignore = true)
    private Long[] deptIds;

    /**
     * 角色菜单权限
     */

    @Column(ignore = true)
    private Set<String> permissions;

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleKey() {
        return roleKey;
    }

    public void setRoleKey(String roleKey) {
        this.roleKey = roleKey;
    }

    public Integer getRoleSort() {
        return roleSort;
    }

    public void setRoleSort(Integer roleSort) {
        this.roleSort = roleSort;
    }

    public String getDataScope() {
        return dataScope;
    }

    public void setDataScope(String dataScope) {
        this.dataScope = dataScope;
    }

    public boolean getMenuCheckStrictly() {
        return menuCheckStrictly;
    }

    public void setMenuCheckStrictly(boolean menuCheckStrictly) {
        this.menuCheckStrictly = menuCheckStrictly;
    }

    public boolean getDeptCheckStrictly() {
        return deptCheckStrictly;
    }

    public void setDeptCheckStrictly(boolean deptCheckStrictly) {
        this.deptCheckStrictly = deptCheckStrictly;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public boolean getFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public Long[] getMenuIds() {
        return menuIds;
    }

    public void setMenuIds(Long[] menuIds) {
        this.menuIds = menuIds;
    }

    public Long[] getDeptIds() {
        return deptIds;
    }

    public void setDeptIds(Long[] deptIds) {
        this.deptIds = deptIds;
    }

    public Set<String> getPermissions() {
        return permissions;
    }

    public void setPermissions(Set<String> permissions) {
        this.permissions = permissions;
    }
}
